<template>
  <el-dialog title="解冻操作" class="freezeAccount" :visible.sync="isShowModel" @close="$emit('update:isShowDetail', false)">
    <el-form :model="freezeInfo" ref="freezeInfo" :rules="rules" label-width="140px">
      <el-form-item label="供应商账号:" required>
        <div class="c-red">
          解冻
        </div>
      </el-form-item>
      <el-form-item label="供应商企业名称:" required>
        <div>
          南京赚他一个亿餐饮管理有限公司
        </div>
      </el-form-item>
      <el-form-item label="操作验证:" prop="productName" required>
        <el-input v-model="freezeInfo.phone">
          <template slot="append">
            <el-button type="text" @click="getPhoneWord" v-if="!isHasValidCode" :loading="isGetInterface">
              {{tipMessage}}
            </el-button>
            <span class="" v-else>{{code}}</span>
          </template>
        </el-input>
      </el-form-item>
      <el-form-item label="验证验证码:" prop="productName" required>
        <el-input v-model="freezeInfo.valit"></el-input>
      </el-form-item>
      <el-form-item label="备注内容:" prop="productName" required>
        <el-input v-model="freezeInfo.productName" type="textarea" :autosize="{ minRows: 6, maxRows: 8}"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="isShowModel = false">取 消</el-button>
      <el-button type="primary" @click="isShowModel = false">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  export default {
    name: "UnFreezeAccount",
    props: {
      isShowDetail: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
        isShowModel: this.isShowDetail,
        freezeInfo: {},
        tipMessage: "发送验证码",
        rules: {},
        isHasValidCode: false,
        // 是否在请求接口
        isGetInterface: false
      }
    },
    methods: {
      getPhoneWord() {
        this.$message.error("获取手机验证码");
        this.isGetInterface = true;
        let time = 60;
        this.tipMessage = time + "秒";
        setInterval(() => {
          if(time <= 0) {
            this.tipMessage = "发送验证码"
            this.isGetInterface = false;
            return ;
          }
          time --;
          this.tipMessage = time + "秒";
        }, 1000)
      }
    },
    watch: {
      isShowDetail(val) {
        this.isShowModel = val
      }
    }
  }
</script>

<style lang="scss">
  .freezeAccount {
    .el-dialog {
      width: 600px;
      .el-input {
        width: 300px;
        .el-button {
          padding: 0 10px;
        }
      }
    }
  }
</style>
